
#delimit;
set more off;

cd "C:\....\Replication files";
	
use "ENMI - replication.dta", clear;


		
xtreg pvote
	c.ensh_mi##i.inc_cab_l, fe robust;
	estimates store ml_simple;
	
	
		
xtreg pvote
	c.ensh_mi##i.inc_cab_l pvote_l
	c.GDPgrowth##i.inc_cab_l 
	
	c.moderate##i.inc_cab_l
 majelect  D1.pctmigrants_inflow
  , fe robust  ;

estimates store ml_full_fe;	


				#delimit;
set more off;
xtreg pvote
	1.inc_cab_l#c.ensh_mi pvote_l c.GDPgrowth
	1.inc_cab_l#c.moderate 
	 majelect  D1.pctmigrants_inflow
  if inc_cab_l==1 , fe robust;
		
testnl _b[c.ensh_mi#1.inc_cab_l] == 0 ;

		estimates store ml_onlyincumbents_fe;
		
						#delimit;

xtreg pvote
	c.ensh_mi c.GDPgrowth pvote_l
	moderate 1.nparty
		 majelect federal directpres 
	 D1.pctmigrants_inflow
		if inc_cab_l==0 , fe robust ;
	
	testnl _b[c.ensh_mi] == 0 ;
	
		estimates store ml_onlyopposition_fe;
		
		
		
#delimit;
 esttab ml_onlyopposition_fe ml_onlyincumbents_fe  ml_full_fe  
	using "figures\Table A17 - Immigration.rtf", replace 
		b (%10.3f) se scalars("aic AIC" "bic BIC" "rmse Root Mean Squared Error" "chi2 \u0935?{\super 2}" "ll Log-Likelihood" ) 
		obslast star(+ 0.10 * 0.05 ** 0.01 *** 0.001)
		label mtitles (  "Opposition" "Incumbents" "Full") nogaps
title (\label{})
		
		
order(ensh_mi 
1.inc_cab_l#c.ensh_mi 
moderate 
1.inc_cab_l#c.moderate 
1.inc_cab_l 
D.pctmigrants_inflow

majelect pvote_l _cons ) 

keep(ensh_mi 1.inc_cab_l 
1.inc_cab_l#c.ensh_mi 1.inc_cab_l#c.moderate 
moderate majelect D.pctmigrants_inflow

pvote_l _cons )  

coeflabels(
ensh_mi "ENMI"  
1.inc_cab_l "Incumbent"
1.inc_cab_l#c.ensh_mi "Incumbent X ENMI"
D.pctmigrants_inflow "Pct change in Immigration rate" 
1.inc_cab_l#c.unemployment "Incumbent X Unemployment Rate"
1.inc_cab_l#c.moderate "Incumbent X Moderated Position"
moderate "Moderated Position"
majelect "Majoritarian Election"
pvote_l "% Vote{\sub t-1}"
_cons "Constant");

